#ifndef __PANEL_H
#define __PANEL_H

#ifdef __cplusplus
 extern "C" {
#endif
   
#include "System.h"

#if ENABLE_LCD
	#define	LCD_ENTER_SLEEP				0X10
	#define	LCD_EXIT_SLEEP				0X11
	#define	LCD_DISPLAY_ON				0X29
	#define	LCD_DISPLAY_OFF				0X28
	 
	#define LCD_COLOR565_BLUE          0x001F
	#define LCD_COLOR565_GREEN         0x07E0
	#define LCD_COLOR565_RED           0xF800
	#define LCD_COLOR565_CYAN          0x07FF
	#define LCD_COLOR565_MAGENTA       0xF81F
	#define LCD_COLOR565_YELLOW        0xFFE0
	#define LCD_COLOR565_LIGHTBLUE     0x841F
	#define LCD_COLOR565_LIGHTGREEN    0x87F0
	#define LCD_COLOR565_LIGHTRED      0xFC10
	#define LCD_COLOR565_LIGHTCYAN     0x87FF
	#define LCD_COLOR565_LIGHTMAGENTA  0xFC1F
	#define LCD_COLOR565_LIGHTYELLOW   0xFFF0
	#define LCD_COLOR565_DARKBLUE      0x0010
	#define LCD_COLOR565_DARKGREEN     0x0400
	#define LCD_COLOR565_DARKRED       0x8000
	#define LCD_COLOR565_DARKCYAN      0x0410
	#define LCD_COLOR565_DARKMAGENTA   0x8010
	#define LCD_COLOR565_DARKYELLOW    0x8400
	#define LCD_COLOR565_WHITE         0xFFFF
	#define LCD_COLOR565_LIGHTGRAY     0xD69A
	#define LCD_COLOR565_GRAY          0x8410
	#define LCD_COLOR565_DARKGRAY      0x4208
	#define LCD_COLOR565_BLACK         0x0000
	#define LCD_COLOR565_BROWN         0xA145
	#define LCD_COLOR565_ORANGE        0xFD20


	//LCD_CS
	#define CLR_CS()	          (Lcd_CS_Port->BRR = Lcd_CS_Pin)
	#define SET_CS()	          (Lcd_CS_Port->BSRR = Lcd_CS_Pin)
	//RS
	#define SET_CMD()	          (Lcd_RS_Port->BRR = Lcd_RS_Pin)
	#define SET_DATA()	          (Lcd_RS_Port->BSRR = Lcd_RS_Pin)
	//RST
	#define RST_LOW()	          (Lcd_RST_Port->BRR = Lcd_RST_Pin)
	#define RST_HI()	          (Lcd_RST_Port->BSRR = Lcd_RST_Pin)

	#define DATA_LOW()	          
	#define DATA_HI()

	// RD
	#define CLR_RD()	          (Lcd_RD_Port->BRR = Lcd_RD_Pin)
	#define SET_RD()	          (Lcd_RD_Port->BSRR = Lcd_RD_Pin)

	// WR
	#define CLR_CLK()	          (Lcd_WR_Port->BRR = Lcd_WR_Pin)
	#define SET_CLK()	          (Lcd_WR_Port->BSRR = Lcd_WR_Pin)


	#define	LCD_DELAY			1
	
typedef enum{
	Lcd_Drive_I8080 = 0,
}LcdInterType_E;
typedef struct{
	UINT32	pixelWidth;
	UINT32	pixelHeight;
	UINT8	wRamCmd;
	UINT8 	setXCmd;
	UINT8 	setYCmd;
	UINT8	colorFormat;
	UINT8	interType;		/*�ӿ�����*/
	struct  inter{
		UINT32	TXECkdiv;
		UINT32	lanes;
		UINT32	PLLdiv;
		UINT32	PLLidf;
		UINT32	PLLodf;
	}mipi_info;
	UINT8	frameRate;
	UINT32	clockDiv;
	UINT32	backColor;                 /*!< Configures the background color. */
}LcdInfo_T;
typedef struct{
	UINT32	HSPolarity;
	UINT32	VSPolarity;
	UINT32	DEPolarity;
	UINT32	PCPolarity;
	UINT32	HSync;   
	UINT32	VSync;  
	UINT32	HBP;  
	UINT32	VBP;   
	UINT32	ActiveW;
	UINT32	ActiveH;    
	UINT32	HFP;        
	UINT32	VFP;      

	UINT32	PLL3M;
	UINT32	PLL3N;
	UINT32	PLL3P;
	UINT32	PLL3Q;
	UINT32	PLL3R;
	
	UINT32	CLHS2LP;
	UINT32	CLLP2HS;
	UINT32	DLHS2LP;
	UINT32	DLLP2HS;
	UINT32	DLMaxRead;
	UINT32	StopWait;
}LcdTiming_T;

void Lcd_DelayUs(UINT32 _us);
void Lcd_WriteByte(UINT8 _data);
void Lcd_SPISendData(UINT8 _cmd,UINT8 _data);
void Lcd_SPISend16BitData(UINT8 _cmd,UINT8 _data);

void Lcd_WReg(UINT8 CMD);
void Lcd_WData(UINT8 DATA);
void Lcd_WData16(UINT16 DATA);

/*************************RGB*****************************/
#if(LCD_PANEL_TYPE == LCD_HDTR024_240X320_TS)
	#include "LCD_HDTR024_240X320_TS.h"
#elif(LCD_PANEL_TYPE == LCD_HDTR035_320X480_TS)
	#include "LCD_HDTR035_320X480_TS.h"

#else
	#error "No Panel"
#endif

		
#endif
#ifdef __cplusplus
}
#endif
#endif
